<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class SMSConfirmationCode extends Model
{
    //
    protected $table = 'xyj_sms_confirmation_code';
    
    public function generateSMSConfirmationCode( $length = 6 )
    {
        return mt_rand(pow(10,($length-1)), pow(10,$length)-1);
    }
    
    /**
     *
     * @param unknown $userCode
     * @param unknown $dbCode
     * @param unknown $expired
     * @return boolean
     */
    public function checkSMSConfirmationCode( $userCode, $dbCode, $expired ){
        if ($userCode == $dbCode && strtotime( $expired ) > time() ){
            return true;
        }else{
            return false;
        }
    }
    
}
